﻿using Game.ui;
using GameFramework.events;
using GameFramework.UI;
using UnityEngine;

public class SetNamingPresenter
{
       public SetNamingPresenter()
       {
              MVPEventManager.Instance.SetNamingView_V2P_SetName += setName;
       }

       private void setName(string name)
       {
              Debug.Log("设置名字："+name);
              if (name == null || name.Length == 0)
              {
                     //TODO 飘字提示名字不正确
                     return;
              }

              if (!nameIsValid(name))
              {
                     //飘字提示名字不合法
                     return;
              }
              //设置到数据
              BaseInfoData baseInfoData = AllData.Instance.mainPlayerData.baseInfoData;
              baseInfoData.Name = name;
              //TODO 其他基本信息的初始化
              baseInfoData.NowExp = 250;
              baseInfoData.MaxExp = 500;
              baseInfoData.HeadIcon = "images/head.jpg";
              UIManager.Instance.show<HomeView>();
       }
       
       private bool nameIsValid(string name)
       {
              return true;
       }
}